<?php
require ('template/header.php');
@session_start();
//$_SESSION['pro'] = array();
if(isset($_SESSION['id'])){
    require './admin/product.php';
    $pro = new product();
    $i = $_SESSION['id'];
    
    $s = isset($_SESSION['size']) ? $_SESSION['size']: '';
    $row = $pro->getProduct($i);
    
    if(isset($row)){
    $row['size']=$s;  
    $row['qty']=1;
    $_SESSION['pro'][$i] = $row;
    }
            
?>
<div class="sb-content">
    <div class="sb-title">
        <h1>Giỏ hàng</h1>
    </div>
    <div class="sb-content">
        <div class="sb-left-content">
            <table  cellspacing="1">
                <tr class="tieude2" >
                    <th ></th>
                    <th ></th>
                    <th >Sản phẩm</th>
                    <th >Số lượng</th>
                    <th >Tổng</th>
                </tr>
                <?php
                    foreach ($_SESSION['pro'] as $value){
                ?>               
                <tr>
                    <td class="sb-sanpham" width="55"><a  class="remove" href="delete_cart.php?id=<?php echo $value['pro_id']?>">x</a></td>
                    <td class="sb-sanpham" width="120"><a href="detail.php?id=<?php echo $value['pro_id']?>"><img src="<?php echo $value['image'];?>" height="72px" width="90px"/></a></td>
                    <td class="sb-sanpham" width="200">
                        <div><a href="detail.php?id=<?php echo $value['pro_id']?>"><?php echo $value['name'];?></a></div>
                        <div style="color:gray; font-size: 13px; margin-top:5px;">Kích cỡ:<?php echo $value['size']?></div>
                        <div style="color:gray; font-size: 14px; margin-top:5px;"><?php echo number_format($value['price']);?>đ</div>
                    </td>       
                    <td width="120">
                        <div class="soluong" style="height: 40px; background: black; width:100px;">
                            <input type="button" class="minus sb-btn" value="-" style="width: 30px; height: 100%;"/>                           
                            <input type="text" name="qty[<?php echo $value['pro_id']?>]" value="<?php echo $value['qty'];?>" style="width:38px; height: 100%;  text-align: center;"/>
                            <input type="button" class="plus sb-btn" value="+" style="width: 30px; height: 100%;"/>
                        </div>
                    </td>
                    <td><?php echo number_format($value['qty']*$value['price']);?>đ</td>
                </tr>
                <?php
                   }
                ?>
            </table>
        </div>
        <div class="sb-right-content">
            <div class="sb-main-right-content">
                <h3>Tổng tiền: <span>250,000</span></h3>
                <h4>Phương thức thanh toán</h4>
                <form>
                    <input type="radio" name="kttk" checked="true" value="1"/><span style="color: gray; font-size: 14px;">Đã có tài khoản</span><br>
                    <input type="radio" name="kttk" value="0"/><span style="color: gray; font-size: 14px;">Chưa có tài khoản</span><br>                
                <p class="sb-button sb-button1">
                    <input class="sb-btn" type="button" value="Thanh toán"/>
                </p>
                </form>
                <form>
                <p class="sb-button sb-button1">              
                    <input class="sb-btn" type="button" name="qty" value="Cập nhật giỏ hảng"/>      
                </p>
                </form>
                <p class="continue">
                    <a href="home.php">>>Tiếp tục mua sắm</a>
                </p>
            </div>
        </div>
    </div>
<?php
}else{
    echo "<p>không có sản phẩm trong giỏ hàng</p>";
}

?>
</div>

<div class="clear-both"></div>
<?php
require ('template/footer.php');
?>
?>